<?php
/* @var $this VanbanphapluatController */
/* @var $model Vanbanphapluat */
/* @var $form CActiveForm */
?>
<script src="<?php echo Yii::app()->baseUrl . '/ckeditor/ckeditor.js'; ?>"></script>
<div class="form">

    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'vanbanphapluat-_vanbanphapluat-form',
        // Please note: When you enable ajax validation, make sure the corresponding
        // controller action is handling ajax validation correctly.
        // See class documentation of CActiveForm for details on this,
        // you need to use the performAjaxValidation()-method described there.
        'enableAjaxValidation' => false,
        'htmlOptions' => array('enctype' => 'multipart/form-data'),
    ));
    ?>



    <?php echo $form->errorSummary($model); ?>

    <div class="form_left">
        <?php echo $form->labelEx($model, 'tieude'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textArea($model, 'tieude', array('style' => 'width: 400px; height: 100px;', 'size' => 70, 'maxlength' => 300, 'required' => 'required')); ?>
        <?php echo $form->error($model, 'tieude'); ?>
    </div>

    <div class="clear"></div>
     <div class="form_left">
        <?php echo $form->labelEx($model, 'url'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textField($model, 'url', array('style' => 'width: 400px;', 'size' => 70, 'maxlength' => 300, 'required' => 'required')); ?>
        <?php echo $form->error($model, 'url'); ?>
    </div>

    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'from'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textField($model, 'from', array('class' => 'easyui-datebox', 'data-options' => 'formatter:myformatter,parser:myparser')); ?>
        <?php echo $form->error($model, 'from'); ?>
    </div>

    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'to'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textField($model, 'to', array('class' => 'easyui-datebox', 'data-options' => 'formatter:myformatter,parser:myparser')); ?>
        <?php echo $form->error($model, 'to'); ?>
    </div>



    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'loai'); ?>
    </div>
    <div class="form_right">
        <?php
        $models = Loaivanban::model()->findAll('flag=1');
        $list = CHtml::listData($models, 'id', 'name');
        echo $form->dropDownList($model, 'loai', $list);
        ?>
        <?php echo $form->error($model, 'loai'); ?>
    </div>

    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'linhvuc'); ?>
    </div>
    <div class="form_right">
        <?php
        $models = Linhvuc::model()->findAll('flag=1');
        $list = CHtml::listData($models, 'id', 'name');
        echo $form->dropDownList($model, 'linhvuc', $list);
        ?>
        <?php echo $form->error($model, 'linhvuc'); ?>
    </div>

    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'coquan'); ?>
    </div>
    <div class="form_right">
        <?php
        $category_ = Coquan::model()->findAll('parent =0 ');

        $arr = array();
        $lan = 0;
        foreach ($category_ as $item) {
            $lan = $lan + 1;
            $catelist = Coquan::model()->findAll('parent = ' . $item->id);

            $arr[$item->id] = $item->name;

            foreach ($catelist as $it) {
                $arr[$it->id] = ' + ' . $it->name;
            }
        }


        echo $form->dropDownList($model, 'coquan', $arr);
        ?>
        <?php echo $form->error($model, 'coquan'); ?>
    </div>

    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'flag'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->dropDownList($model, 'flag', array('0'=>'Đang ẩn','1'=>'Đang hiện')); ?>
        <?php echo $form->error($model, 'flag'); ?>
    </div>

    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'file'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->fileField($model, 'file', array('size' => 40, 'maxlength' => 50)); ?>
        <?php echo $form->error($model, 'file'); ?>
    </div>

    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'noidung'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textArea($model, 'noidung', array('id' => 'editor1')); ?>
        <?php echo $form->error($model, 'noidung'); ?>
    </div>

    <div class="clear"></div>
    <div class="form_left">
    </div>
    <div class="form_right">
        <?php echo CHtml::submitButton('Cập nhật'); ?>
    </div>

    <?php $this->endWidget(); ?>

    <script type="text/javascript">
        CKEDITOR.replace('editor1', {
            filebrowserBrowseUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/browse.php?type=files',
            filebrowserImageBrowseUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/browse.php?type=images',
            filebrowserFlashBrowseUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/browse.php?type=flash',
            filebrowserUploadUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/upload.php?type=files',
            filebrowserImageUploadUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/upload.php?type=images',
            filebrowserFlashUploadUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/upload.php?type=flash'
        });
    </script>

    <script type="text/javascript">
        function myformatter(date) {
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            var d = date.getDate();
            return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d);
        }
        function myparser(s) {
            if (!s)
                return new Date();
            var ss = (s.split('-'));
            var y = parseInt(ss[0], 10);
            var m = parseInt(ss[1], 10);
            var d = parseInt(ss[2], 10);
            if (!isNaN(y) && !isNaN(m) && !isNaN(d)) {
                return new Date(y, m - 1, d);
            } else {
                return new Date();
            }
        }
    </script>
</div><!-- form -->